package org.onvivals.module.ums.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.onvivals.common.enums.BillEnum;
import org.onvivals.module.ums.entity.UmsUserBill;
import org.onvivals.module.ums.mapper.UmsUserBillMapper;
import org.onvivals.module.ums.service.IUmsUserBillService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;

@Service
public class UmsUserBillServiceImpl extends ServiceImpl<UmsUserBillMapper, UmsUserBill> implements IUmsUserBillService {
	/**
	 * 增加收入/支入流水
	 *
	 * @param uid      uid
	 * @param title    账单标题
	 * @param category 明细种类
	 * @param type     明细类型
	 * @param number   明细数字
	 * @param balance  剩余
	 * @param mark     备注
	 * @param linkid   关联id
	 */
	@Override
	public void income(Long uid, String title, String category, String type, double number,
					   double balance, String mark, String linkid, Date time) {
		UmsUserBill userBill = UmsUserBill.builder()
				.uid(uid)
				.title(title)
				.category(category)
				.type(type)
				.number(BigDecimal.valueOf(number))
				.balance(BigDecimal.valueOf(balance))
				.mark(mark)
				.pm(BillEnum.PM_1.getValue())
				.linkId(linkid)
				.vipExpireTime(time)
				.build();

		baseMapper.insert(userBill);
	}
}
